package contract;

import java.util.Calendar;
import event.Event;
import budget.Budget;

public class EventContract extends Contract{
	public EventContract(long id, Calendar stipulationDate, Calendar validityDate, String clauses, Budget budget) {
		this(id, stipulationDate, validityDate, clauses,budget,false);
		
	}
	public EventContract(long id, Calendar stipulationDate, Calendar validityDate, String clauses, Budget budget,boolean locked) {
		super(id, stipulationDate, validityDate, clauses);
		this.locked=locked;
		this.budget=budget;	
	}
	
	public Budget getBudget() {
		return budget;
	}
	public void lock(){
		this.locked=true;
	}
	public boolean isLocked(){
		return this.locked;
	}
	public void setBudget(Budget budget) {
		if (!locked)
		this.budget = budget;
	}
	
	public Event getEvent() {
		return budget.getRequest().getEvent();
	}
	
	public boolean contains(String filter){
		String string = this.getClauses() +" "+ this.getId();
		if(string.contains(filter) || budget.contains(filter))
			return true;
		return false;
	}
	private boolean locked;
	private Budget budget;
}
